package Tests.ChessPieces;

import static org.junit.Assert.*;

import java.rmi.RemoteException;

import Models.ChessPieceModel;
import Models.Player;
import Models.StandardChessPieceModel;
import Models.StandardPlayer;
import Models.StandardPoint2D;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import Controllers.KingController;

public class KingControllerTest {
	private KingController kingController;
	private Player player;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		kingController = new KingController();
		player = new StandardPlayer();
	}

	@Test
	public void testLegalMove() {
		try {
			ChessPieceModel model = new StandardChessPieceModel(player);
			Assert.assertTrue(kingController.legalMove(new StandardPoint2D(0,1), model)); 
			Assert.assertTrue(kingController.legalMove(new StandardPoint2D(1,1), model));
			Assert.assertTrue(kingController.legalMove(new StandardPoint2D(1,0), model));
			Assert.assertTrue(kingController.legalMove(new StandardPoint2D(1,-1), model));
			Assert.assertTrue(kingController.legalMove(new StandardPoint2D(0,-1), model));
			Assert.assertTrue(kingController.legalMove(new StandardPoint2D(-1,-1), model));
			Assert.assertTrue(kingController.legalMove(new StandardPoint2D(-1,0), model));
			Assert.assertTrue(kingController.legalMove(new StandardPoint2D(-1,1), model));
			
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@Test
	public void testIlegalMove() {
		try {
			ChessPieceModel model = new StandardChessPieceModel(player);
			Assert.assertFalse(kingController.legalMove(new StandardPoint2D(0,2), model));
			Assert.assertFalse(kingController.legalMove(new StandardPoint2D(-1,2), model));
			Assert.assertFalse(kingController.legalMove(new StandardPoint2D(2,0), model));
			
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	

}
